<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{$title}</title>
<link rel="stylesheet" type="text/css" href="Res/index/css/Iframe.css" />
<link rel="stylesheet" href="Res/index/utilLib/bootstrap.min.css" type="text/css" media="screen" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<script type="text/javascript" src="Res/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="Res/js_time/laydate.js"></script>
</head>

<body>
<span class="cp_title">管理员用户管理</span>
<div class="add_cp">
	<a href="index.php?c=user&m=view">返回管理员用户列表</a>
</div>
<div class="table_con" style="margin: 0 auto;text-align: center;">
    <form class="form-horizontal" role="form" action="index.php?c=user&m={$act}" method="post">
    <div class="form-group">
        <label for="user_name" class="col-sm-2 control-label">用户名：</label>
        <div class="col-sm-5">
            {if $user_row.user_id gt 0}
            <input type="text" disabled="true" autocomplete="off" class="form-control" value="{$user_row.user_name}" name="user_name" id="user_name" placeholder="用户名称" />
            {else}
            <input type="text" autocomplete="off" class="form-control" value="{$cookie.user_name}" name="user_name" id="user_name" placeholder="用户名称" />
            {/if}
        </div>
    </div>
    <div class="form-group">
        <label for="user_pass" class="col-sm-2 control-label">邮箱：</label>
        <div class="col-sm-5">
            {if $user_row.user_id gt 0}
                <input type="text" value="{$user_row.email}" autocomplete="off" class="form-control" id="email" name="email" placeholder="邮箱" />
            {else}
                <input type="text" autocomplete="off" value="{$cookie.email}" class="form-control" id="email" name="email" placeholder="邮箱" />
            {/if}            
        </div>
    </div>
    <div class="form-group">
        <label for="user_pass" class="col-sm-2 control-label">开始时间：</label>
        <div class="col-sm-5">
            {if $user_row.user_id gt 0}
                <input type="text" value="{$user_row.start_time}"autocomplete="off" class="form-control laydate-icon" style="height: 36px;" id="start_time" name="start_time" placeholder="开始时间" />
            {else}
                <input type="text" autocomplete="off" value="{$cookie.start_time}" class="form-control laydate-icon" style="height: 36px;" id="start_time" name="start_time" placeholder="开始时间" />
            {/if}
        </div>
    </div>
    <div class="form-group">
        <label for="user_pass" class="col-sm-2 control-label">结束时间：</label>
        <div class="col-sm-5">
            {if $user_row.user_id gt 0}
                <input type="text" value="{$user_row.end_time}" autocomplete="off" class="form-control laydate-icon" style="height: 36px;" id="end_time" name="end_time" placeholder="结束时间" />
            {else}
                <input type="text" autocomplete="off" value="{$cookie.end_time}" class="form-control laydate-icon" style="height: 36px;" id="end_time" name="end_time" placeholder="结束时间" />
            {/if}
        </div>
    </div>
    <div class="form-group">
        <label for="user_pass" class="col-sm-2 control-label">计算时间差：</label>
        <div class="col-sm-1">
            <input type="button" class="btn btn-success" value="计算" id="btn_calc" />            
        </div>
        <div class="col-sm-2">
            <span id="calc_result"></span>
        </div>
    </div>
    <div class="form-group">
        <label for="user_pass" class="col-sm-2 control-label">密码：</label>
        <div class="col-sm-5">
            <input type="password" autocomplete="off" class="form-control" id="user_pass" name="user_pass" placeholder="密码" />
        </div>
    </div>
    <div class="form-group">
        <label for="user_pass_confirm" class="col-sm-2 control-label">确认密码：</label>
        <div class="col-sm-5">
          <input type="password" autocomplete="off" class="form-control" id="user_pass_confirm" name="user_pass_confirm" placeholder="确认密码" />
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-5">
            <input type="hidden" value="{$token}" name="token" />
            {if $user_row}
            <input type="hidden" value="{$user_row.user_id}" name="user_id" />
            {/if}
            <button type="submit" class="btn btn-primary btn-lg btn-block">{$title}</button>            
        </div>
    </div>
    </form>
</div>
<script>
    $(function(){
        $("#btn_calc").click(function(){
            var start = $("#start_time").val();
            var end = $("#end_time").val();
            var dt1 = new Date(Date.parse(start.replace(/-/g,   "/")));
            var dt2 = new Date(Date.parse(end.replace(/-/g,   "/")));   
            var diff = parseInt(dt2.getTime() - dt1.getTime()) / 1000; //工作天数
            var t = calc_time(diff);
            var time_str = t['d'] + '天' + t['h'] + '小时' + t['m'] + '分' + t['s'] + '秒';
            $("#calc_result").html("租赁时间：" + time_str);
        });
    });
var start = {
    elem: '#start_time',
    format: 'YYYY-MM-DD hh:mm:ss',
    min: laydate.now(), //设定最小日期为当前日期
    max: '2099-06-16 23:59:59', //最大日期
    istime: true,
    istoday: false,
    festival: true, //是否显示节日
    choose: function(datas){
         end.min = datas; //开始日选好后，重置结束日的最小日期
         end.start = datas; //将结束日的初始值设定为开始日
    }
};
var end = {
    elem: '#end_time',
    format: 'YYYY-MM-DD hh:mm:ss',
    min: laydate.now(),
    max: '2099-06-16 23:59:59',
    istime: true,
    istoday: false,
    festival: true, //是否显示节日
    choose: function(datas){
        start.max = datas; //结束日选好后，重置开始日的最大日期
    }
};
laydate(start);
laydate(end);
laydate.skin("yalan");
function calc_time(diff){
    var arr = new Array();
    var t = 24 * 60 * 60;
    var day = Math.floor(diff/t);
    var hour = Math.floor((diff - day * t)/3600);
    var minute = Math.floor((diff - day * t - hour * 3600)/60);
    var second = Math.floor(diff - day * t - hour * 3600 - minute*60);
    arr['d'] = day;
    arr['h'] = hour;
    arr['m'] = minute;
    arr['s'] = second;
    return arr;
}
</script>
</script>
</body>
</html>

